package com.sca.webservice.service.impl;

import com.sca.webservice.service.TestService;
import org.springframework.stereotype.Component;

import javax.jws.WebService;
import java.io.*;

/**
 * @Author: denglei
 * @Date: 2022/1/13 09:13
 * @Description:
 */
@WebService(name = "test" ,targetNamespace ="http://service.webservice.sca.com/" ,endpointInterface = "com.sca.webservice.service.TestService")
@Component
public class TestServiceImpl implements TestService {
    @Override
    public String deliveryService(String id) throws UnsupportedEncodingException {
        String fileUrl = "F:\\主数据-客户.txt";
        return readFileContent(fileUrl);
    }
//    @Override
//    public User getUser(String id)throws UnsupportedEncodingException  {
//        return new User(2L,"zhangsan");
//    }


    private String readFileContent(String fileName) {
        File file = new File(fileName);
        BufferedReader reader = null;
        StringBuffer sbf = new StringBuffer();
        try {
            reader = new BufferedReader(new FileReader(file));
            String tempStr;
            while ((tempStr = reader.readLine()) != null) {
                sbf.append(tempStr);
            }
            reader.close();
            return sbf.toString();
        } catch (IOException e) {
            e.printStackTrace();
        } finally {
            if (reader != null) {
                try {
                    reader.close();
                } catch (IOException e1) {
                    e1.printStackTrace();
                }
            }
        }
        return sbf.toString();
    }
}
